package com.smritimap.demo;

import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;

import com.smritimap.demo.fragment.MemoryCreateStepFrag;
import com.smritimap.demo.fragment.DrawCanvasFragment;
import com.smritimap.demo.fragment.HorizontalStepviewFragment;
import com.smritimap.demo.fragment.VerticalStepViewReverseFragment;
import com.smritimap.demo.fragment.VerticalStepViewFrowardFragment;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //SmritiMapFragment fragment = new SmritiMapFragment();
        //HorizontalStepviewFragment fragment = new HorizontalStepviewFragment();

        MemoryCreateStepFrag fragment = MemoryCreateStepFrag.newInstance();
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.stepContainer, fragment)
                .commit();

        //ArrowActivity.jumpTo(this);
        //TestHorizontalStepViewActivity.jumpTo(this);
        //ArcArrowActivity.jumpTo(this);
        //ArcActivity.jumpTo(this);
        //ArcAngleArrowActivity.jumpTo(this);
        //CanvasRotateActivity.jumpTo(this);
        //SmritiTreeActivity.jumpTo(this);
        //DrawableLoadActivity.jumpTo(this);
        //CustomImageViewActivity.jumpTo(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.menu_main_activity, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        VerticalStepViewReverseFragment mVerticalStepViewFragment;
        DrawCanvasFragment mDrawCanvasFragment;
        HorizontalStepviewFragment mHorizontalStepviewFragment;
        VerticalStepViewFrowardFragment mVerticalStepViewReverseFragment;
        FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
        int itemId = item.getItemId();
        if (itemId == R.id.action_horizontal_stepview) {
            mHorizontalStepviewFragment = new HorizontalStepviewFragment();
            fragmentTransaction.replace(R.id.stepContainer, mHorizontalStepviewFragment).commit();
        }

        if (itemId == R.id.action_drawcanvas) {
            mDrawCanvasFragment = new DrawCanvasFragment();
            fragmentTransaction.replace(R.id.stepContainer, mDrawCanvasFragment).commit();
        }

        if (itemId == R.id.action_vertical_reverse) {
            mVerticalStepViewFragment = new VerticalStepViewReverseFragment();
            fragmentTransaction.replace(R.id.stepContainer, mVerticalStepViewFragment).commit();
        }

        if (itemId == R.id.action_vertical_forward) {
            mVerticalStepViewReverseFragment = new VerticalStepViewFrowardFragment();
            fragmentTransaction.replace(R.id.stepContainer, mVerticalStepViewReverseFragment).commit();
        }

        if (itemId == R.id.action_test_horizontal_stepview) {
            startActivity(new Intent(this, TestHorizontalStepViewActivity.class));
        }
        return super.onOptionsItemSelected(item);
    }
}